//导入moment
import moment from 'moment';
import Vue from 'vue';

//注册全局过滤器
Vue.filter('datetime', function (value, format = 'YYYY-MM-DD HH:mm:ss') {
  return moment(value).format(format);
})


Vue.filter('date', function (value, format = 'YYYY-MM-DD') {
  return moment(value).format(format);
})


Vue.filter('afterDate', function (value, format = 'YYYY-MM-DD') {
  let date = moment(value).add(-13, 'hour').format('YYYY-MM-DD HH:mm:ss')
  return date;
})

//格式化Map对象 去{}
Vue.filter('formateMapForStr', (value) => {
  let str = '';
  for (const key in value) {
    if (value.hasOwnProperty(key)) {
      const element = value[key];
      str = key.substring(0,key.length-11) + "x" + element ;
    }
  }
  
  return str;
})

//去除门票后的时间
Vue.filter('formateDelTime', (value) => {
  let s1 = value.substring(0,value.length-11);
  // console.log(s1);
  return s1;
})

